package com.steakliu.sun.test.client;

import com.steakliu.sun.client.SunClient;
import com.steakliu.sun.client.api.ClientConfig;
import com.steakliu.sun.test.api.UserService;
import org.junit.Test;

/**
 * 功能说明：
 * <p>
 * Original @Author: steakliu-刘牌, 2023-01-08  01:43
 * <p>
 * Copyright (C)2020-2022  steakliu All rights reserved.
 */
public class NettyClientTest2 {

    @Test
    public void startNettyClient() throws Exception {
        ClientConfig config = ClientConfig.builder()
                .version("1.0.0")
                .group("sun")
                .registryType("nacos")
                .registryAddress("localhost:8848")
                .serializer("jdk")
                .loadBalance("random")
                .oneway(false)
                .async(false)
                //.timeout(5000)
                .token("123456")
                .heartbeatInterval(10000)
                .heartbeatRetries(3)
                //.directConnections(IpUtil.getHost()+":20021")
                .useFlowControl(true)
                .flowControlType("print")

                .build();
        SunClient sunClient = new SunClient(config);
        UserService userService = sunClient.create(UserService.class);
        String user = userService.getUser("liuP");
        System.out.println("user =================> "+user);
        while (true){
            Thread.sleep(1000);
        }
    }
}
